package com.springboot.exceptions.message;

import com.springboot.enums.CodeEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 接口返回信息
 *
 * @author tangn
 */
@Data
@NoArgsConstructor
@SuppressWarnings("unused")
public class MessageBean<T> implements Serializable {
    private static final long serialVersionUID = 7192766535561421181L;
    private String msg;
    private T data;
    private Integer code;

    public MessageBean(CodeEnum code, T data, String errorMsg) {
        this.code = code.getCode();
        this.data = data;
        this.msg = errorMsg;
    }

    public MessageBean(CodeEnum code, String errorMsg) {
        this.code = code.getCode();
        this.msg = errorMsg;
    }

    public MessageBean(CodeEnum code) {
        this.code = code.getCode();
        this.msg = code.getMessage();
    }
}